//
//  TopicCell.m
//  Topic1
//
//  Created by 孙添凤 on 16/12/8.
//  Copyright © 2016年 孙添凤. All rights reserved.
//

#import "TopicCell.h"
#import "Masonry.h"
#import "UIColor+CL.h"
@implementation TopicCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

-(instancetype)initIdentifier:(NSString *)identifer{
    self=  [super initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifer];
    if(self){
        UIView *superView = [self createUI];
        [self.contentView addSubview:superView];
        UIView *superview = self.contentView;
        UIEdgeInsets edge = UIEdgeInsetsMake(0, 0, 0, 0);
        [superView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.edges.equalTo(superview).insets(edge);
        }];
        
    }
    return self;
}

-(UIView *)createUI{
    
    
    UIView *baseView = [[UIView alloc]init];
    
    
    _systemImg =[[UIImageView alloc]init];
    [baseView addSubview:_systemImg];
    [_systemImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(baseView.mas_left).offset(21);
        make.centerY.equalTo(baseView.mas_centerY);
        make.width.equalTo(@(38));
        make.height.equalTo(@(38));
    }];
//    _systemImg.backgroundColor =[UIColor colorWithHex:0x00cdcd];
    _systemImg.image =[UIImage imageNamed:@"system_message"];
    
    _systemTitle =[[UILabel alloc]init];
    [baseView addSubview:_systemTitle];
    _systemTitle.text = @"系统消息";
    [_systemTitle sizeToFit];
    [_systemTitle mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_systemImg.mas_right).offset(15);
        make.centerY.equalTo(baseView.mas_centerY);
        make.height.equalTo(@(16));
    }];
    _systemTitle.textColor = [UIColor colorWithHex:0x333333];
    _systemTitle.font =[UIFont systemFontOfSize:18];
    
    _sysNumLa =[[UILabel alloc]init];
    [baseView addSubview:_sysNumLa];
    [_sysNumLa sizeToFit];
    [_sysNumLa mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(baseView.mas_right).offset(-15);
        make.centerY.equalTo(baseView.mas_centerY);
        make.width.equalTo(@(16));
        make.height.equalTo(@(16));
    }];
    _sysNumLa.layer.cornerRadius = 8;
    _sysNumLa.layer.masksToBounds = YES;
    _sysNumLa.backgroundColor =[UIColor colorWithHex:0xf43530];
    _sysNumLa.textColor =[UIColor whiteColor];
    _sysNumLa.text = @"6";
    _sysNumLa.font =[UIFont systemFontOfSize:11];
    _sysNumLa.textAlignment = NSTextAlignmentCenter;
    _sysNumLa.hidden = YES;
    
    
    _img =[[UIImageView alloc]init];
    [baseView addSubview:_img];
    [_img mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(baseView.mas_left).offset(15);
        make.centerY.equalTo(baseView.mas_centerY);
        make.width.equalTo(@(50));
        make.height.equalTo(@(50));
    }];
    _img.backgroundColor =[UIColor colorWithHex:0x00cdcd];
    _img.layer.cornerRadius = 25;
//    _img.image =[UIImage imageNamed:@"default_portrait"];
    _img.layer.masksToBounds = YES;
    
    _name =[[UILabel alloc]init];
    [baseView addSubview:_name];
    _name.text = @"gogog";
    [_name sizeToFit];
    [_name mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_img.mas_right).offset(15);
        make.top.equalTo(baseView.mas_top).offset(20);
        make.height.equalTo(@(16));
        make.width.equalTo(@(200));
    }];
    _name.textColor = [UIColor colorWithHex:0x333333];
    _name.font =[UIFont systemFontOfSize:16];
    
    _people =[[UILabel alloc]init];
    [baseView addSubview:_people];
     [_people sizeToFit];
    [_people mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_img.mas_right).offset(20);
        make.top.equalTo(_name.mas_bottom).offset(10);
        make.right.equalTo(baseView.mas_right).offset(-20);
        make.height.equalTo(@(14));
    }];
    _people.text = @"dfsdfsdfsdfsdfsdf";
    _people.textColor = [UIColor colorWithHex:0x858585];
    _people.font =[UIFont systemFontOfSize:14];
    _people.numberOfLines = 0;
    
    _timeLa =[[UILabel alloc]init];
    [baseView addSubview:_timeLa];
    [_timeLa sizeToFit];
    [_timeLa mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(baseView.mas_right).offset(-15);
        make.top.equalTo(baseView.mas_top).offset(20);
        make.width.equalTo(@(70));
        make.height.equalTo(@(16));
    }];
    _timeLa.text = @"14:25";
    _timeLa.textColor =[UIColor colorWithHex:0xafafaf];
    _timeLa.textAlignment = NSTextAlignmentRight;
    _timeLa.font = [UIFont systemFontOfSize:12];
    
    _numLa =[[UILabel alloc]init];
    [baseView addSubview:_numLa];
    [_numLa sizeToFit];
    [_numLa mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(baseView.mas_right).offset(-15);
        make.top.equalTo(_timeLa.mas_bottom).offset(8);
        make.width.equalTo(@(16));
        make.height.equalTo(@(16));
    }];
    _numLa.layer.cornerRadius = 8;
    _numLa.layer.masksToBounds = YES;
    _numLa.backgroundColor =[UIColor colorWithHex:0xf43530];
    _numLa.textColor =[UIColor whiteColor];
    _numLa.text = @"10";
    _numLa.font =[UIFont systemFontOfSize:11];
    _numLa.textAlignment = NSTextAlignmentCenter;
    _numLa.hidden = YES;
    
    UIView *line =[[UIView alloc]init];
    [baseView addSubview:line];
    [line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(baseView.mas_left).offset(18);
        make.right.equalTo(baseView.mas_right);
        make.bottom.equalTo(baseView.mas_bottom);
        make.height.equalTo(@(0.5));
    }];
    line.backgroundColor =[UIColor colorWithHex:0xd6d7dc];
    
    
    return baseView;
}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
